import { View } from "../../../mvc/core/View";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { Language } from "../../../../extend/language/Language";
import { GTextFormat } from "../../../common/GTextFormat";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { LuckyShowRenderer } from "./LuckyShowRenderer";
import { SPublicNotice } from "../../../../Message/Public/SPublicNotice";
import { ChatMessageWorking } from "../chat/chatViewData/ChatMessageWorking";
import { PlayerAndItemInfo } from "./PlayerAndItemInfo";
import { DataProvider } from "../../../../fl/data/DataProvider";
type int = number;
//class TreasureLuckyShowPanel
    
    export  class TreasureLuckyShowPanel extends View
    {
        constructor()
        {
            super();
            this._publicNoticeArr = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBitmap(ImagesConst.Fire, 120, -2, this);
            var loc2=ObjCreate.createTextField(Language.getString(35006), 145, 5, 200, 20, this, new GTextFormat("", 12, 16776960));
            this._tileList = new GTileList();
            this._tileList.columnWidth = 38;
            this._tileList.rowHeight = 38;
            this._tileList.columnCount = 8;
            this._tileList.rowCount = 1;
            this._tileList.horizontalGap = 10;
            this._tileList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._tileList.setStyle("cellRenderer", LuckyShowRenderer);
            this._tileList.setSize(380, 40);
            this._tileList.move(25, 27);
            addChild(this._tileList);
            return;
        }

        public updateDataProvider(arg1: Array<any>): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc9=null;
            var loc10=0;
            var loc11=null;
            this._publicNoticeArr.splice(0);
            var loc1=arg1.length;
            var loc8=0;
            while (loc8 < loc1) 
            {
                loc2 = arg1[loc8] as SPublicNotice;
                if ((loc3 = ChatMessageWorking.getPlayerAndItem(loc2)) != null) 
                {
                    if ((loc4 = loc3.itemDatas) != null) 
                    {
                        loc10 = 0;
                        while (loc10 < loc4.length) 
                        {
                            loc5 = loc4[loc10];
                            (loc7 = new PlayerAndItemInfo()).itemData = loc5;
                            loc7.player = loc3.player;
                            this._publicNoticeArr.push(loc7);
                            ++loc10;
                        }
                    }
                }
                ++loc8;
            }
            if (this._publicNoticeArr.length > 8) 
            {
                this._startIdx = this._publicNoticeArr.length - 8;
                this._endIdx = this._publicNoticeArr.length;
                loc11 = this._publicNoticeArr.slice(this._startIdx);
                loc9 = new DataProvider(loc11);
            }
            else 
            {
                loc9 = new DataProvider(this._publicNoticeArr);
            }
            this._tileList.dataProvider = loc9;
            return;
        }

        /* internal  */onLeftBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            if (this._startIdx > 0) 
            {
                --this._startIdx;
                --this._endIdx;
                loc1 = this._publicNoticeArr.slice(this._startIdx, this._startIdx + 8);
                this._tileList.dataProvider = new DataProvider(loc1);
            }
            return;
        }

        /* internal  */onRightBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            if (this._endIdx < this._publicNoticeArr.length) 
            {
                this._endIdx = this._endIdx + 1;
                this._startIdx = this._startIdx + 1;
                loc1 = this._publicNoticeArr.slice(this._startIdx, this._startIdx + 8);
                this._tileList.dataProvider = new DataProvider(loc1);
            }
            return;
        }

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_publicNoticeArr: Array<any>;

        /* internal */ /* var */_startIdx: int;

        /* internal */ /* var */_endIdx: int;
    }
